<template>
  <!--<div id="app" @click="clicked">-->
  <div id="app">
    <router-view/>
    <audio ref="audio" src="../static/8855.mp3" style="display: none"  > </audio>
    <el-dialog title="有客人下单了" :visible.sync="orderVisible" width="500px" :modal-append-to-body="false">
      <el-form>
        <el-form-item label="订单号：" :label-width="formLabelWidth" prop="user_password">
          <span>{{orderData.ordernum}}</span>
        </el-form-item>
        <el-form-item label="用户昵称：" :label-width="formLabelWidth" prop="user_name">
          <span>{{orderData.nickname}}</span>
        </el-form-item>
        <!--<el-form-item label="状态：" :label-width="formLabelWidth" prop="user_password">-->
        <!--<span>{{pdlx1(orderData.state)}}</span>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="KTV名称：" :label-width="formLabelWidth" prop="user_password">-->
        <!--<span>{{orderData.ktv_name}}</span>-->
        <!--</el-form-item>-->
        <el-form-item label="包房：" :label-width="formLabelWidth" prop="user_account">
          <span>{{pdlx(orderData.type)}}</span>
        </el-form-item>
        <el-form-item label="场次：" :label-width="formLabelWidth" prop="user_account">
          <span>{{pdlx2(orderData.session_type)}}</span>
        </el-form-item>
        <el-form-item label="时间段：" :label-width="formLabelWidth" prop="user_account">
          <span>{{orderData.start_time}} - {{orderData.over_time}}</span>
        </el-form-item>
        <el-form-item label="下单时间：" :label-width="formLabelWidth" prop="user_account">
          <span>{{formatDate(orderData.addtime)}}</span>
        </el-form-item>
      </el-form>
      <div>

      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="goOrder(1)">立即查看</el-button>
        <el-button @click="orderVisible = false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="客人取消订单" :visible.sync="orderVisibleFalse" width="500px" :modal-append-to-body="false">
      <el-form>
        <el-form-item label="订单号：" :label-width="formLabelWidth" prop="user_password">
          <span>{{orderData.ordernum}}</span>
        </el-form-item>
        <el-form-item label="用户昵称：" :label-width="formLabelWidth" prop="user_name">
          <span>{{orderData.nickname}}</span>
        </el-form-item>
        <!--<el-form-item label="状态：" :label-width="formLabelWidth" prop="user_password">-->
        <!--<span>{{pdlx1(orderData.state)}}</span>-->
        <!--</el-form-item>-->
        <!--<el-form-item label="KTV名称：" :label-width="formLabelWidth" prop="user_password">-->
        <!--<span>{{orderData.ktv_name}}</span>-->
        <!--</el-form-item>-->
        <el-form-item label="包房：" :label-width="formLabelWidth" prop="user_account">
          <span>{{pdlx(orderData.type)}}</span>
        </el-form-item>
        <el-form-item label="场次：" :label-width="formLabelWidth" prop="user_account">
          <span>{{pdlx2(orderData.session_type)}}</span>
        </el-form-item>
        <el-form-item label="时间段：" :label-width="formLabelWidth" prop="user_account">
          <span>{{orderData.start_time}} - {{orderData.over_time}}</span>
        </el-form-item>
        <el-form-item label="下单时间：" :label-width="formLabelWidth" prop="user_account">
          <span>{{formatDate(orderData.addtime)}}</span>
        </el-form-item>
      </el-form>
      <div>

      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="goOrder(2)">立即查看</el-button>
        <el-button @click="orderVisibleFalse = false">取 消</el-button>
      </div>
    </el-dialog>

    <template><span v-loading.fullscreen.lock="Loading"></span></template>
  </div>
</template>

<script>
  export default {
    name: 'App',
    created(){
      if (!this.$store.state.login.in) {
        this.$router.push({name: "login", params: {userId: 123}})
      }
      //在页面刷新时vuex的数据不消失
      window.addEventListener("beforeunload", () => {
        let s=this.$store.state.login
        for(let i in s){
          this.$store.commit('states',{key:i,value:s[i]})
        }
      });
    },
    computed: {
      Loading() {
        return this.$store.state.login.Loading
      },
      isShow(){
        return this.$store.state.login.Noticenews
      },
      isShow2(){
        return this.$store.state.login.NoticenewsFalse
      },
      audioPlay(){
        return this.$store.state.login.NoticeAudio
      }
    },
    watch: {
      isShow() {
        this.seeOrder()
      },
      isShow2() {
        this.seeOrder()
      },
      audioPlay(){
        this.$refs.audio.play()
      }
    },
    data (){
      return {
        timeOut: '',
        formLabelWidth:'100px',
        orderData:[],
        orderVisible:false,
        orderVisibleFalse:false,
      }
    },

    methods:{
      clicked () {
        let that = this;
        clearInterval(that.timeOut);
        that.timeOut = setInterval(function () {
          that.$store.commit('logout');
          that.$router.push({name: "login", params: {userId: 123}})
        },1000 * 60 * 10)
      },
      pdlx(type){
        let dateArr = ['小包','中小包','大包','豪包',];
        return dateArr[type]
      },
      pdlx1(type){
        let dateArr = ['使用','未使用','进行中','待评价','已评价','已取消',];
        return dateArr[type]
      },
      pdlx2(type){
        let dateArr = ['上午场','下午场','黄金场','午夜场',];
        return dateArr[type]
      },
      seeOrder(){
        let thi = this
        const prams = {
          order_id:thi.$store.state.login.newsNotice.order_id
        }
        thi.mySelectAll('orderInfo',prams).then(function (value) {
          thi.orderData = value.data
          if (thi.$store.state.login.newsNotice.type == 1) {
            thi.orderVisible = true
          }
          if (thi.$store.state.login.newsNotice.type == 2) {
            thi.orderVisibleFalse = true
          }

        })
      },
      goOrder(type){
        if (type == 1){
          this.orderVisible = false
          this.$router.push({name:'reserveOrder'})
        }
        if (type == 2) {
          this.orderVisibleFalse = false
          this.$router.push({name:'cancelReserveOrder'})
        }

      }
    }
  }
</script>

<style>
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
  }
  body,html{
    margin: 0;
    padding: 0;
  }

  .breadcrumb{
    background-color: white;
    height: 20px;
    line-height: 20px;
    padding: 15px;
    font-size: 14px;
    border-bottom: solid 1px #EDEDED;
  }
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    background-color: white;
  }


  /*定义滚动条轨道 内阴影+圆角*/

  ::-webkit-scrollbar-track {
    /* -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); */
    border-radius: 8px;
    background-color: white;
  }


  /*定义滑块 内阴影+圆角*/

  ::-webkit-scrollbar-thumb {
    border-radius: 10px;
    /*-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);
    background-color: #555; */
    width: 8px;
    height: 8px;
    background: rgba(225, 228, 229, 1);
  }
  .el-input__inner .gc{
    border: none;
    margin-left: -9px;
  }
  .schedule .item:first-child .el-input__inner, .gc{
    border: none;
    margin-left: -9px;
    color: #67C23A;
  }
  .admin-body{
    min-width: 600px;
  }
  .kz_search .el-input__inner {
    border-color: #409EFF;
  }

  .kz_search .el-input-group__append {
    background-color: #409EFF !important;
    border-radius: 0 3px 3px 0;
    border-color: #409EFF;
    color: #ffffff;
  }
</style>
